<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>正则表达式验证邮箱是否合法</title>
 <script type="text/javascript">
	function Test()
	{
		var Anval=document.getElementById("wb");
		var text =Anval.value;
		//alert(text);
		var Mre=/(\w+@{1}\w+\.{1}\w{3})/gi;
		var res=Mre.exec(text)
		alert(res.length+""+res);
		/*if(res!=null && res.length==1)
		{
			alert("邮箱格式正确！");
		}
		else
		{
			alert("邮箱格式不正确！");
		}*/
	}
 </script>
 </head>
 <body>
	<textarea autofocus="autofocus" id="wb" cols="30" rows="1"></textarea>
	<input type="button" id="An" value="验证" onclick="Test();">
 </body>
 </html>